<?php
define('IN_ECS', true);

require(dirname(__FILE__) . '/includes/init.php');

/* 检查权限 */
admin_priv('users_manage');

if(isset($_REQUEST['act']) && $_REQUEST['act']=='save'){
	$url = $_POST['site_url'];
	$stage = $_POST['stage_id'];
	$border = $_POST['border_id'];
	$jewelry = $_POST['jewelry_id'];
	$calendar = $_POST['calendar_id'];

	$sql = "update diyconfig set site_url='$url', stage_id=$stage, border_id=$border, jewelry_id=$jewelry, calendar_id=$calendar";
	//echo var_dump($sql);
	$re = $GLOBALS['db']->query($sql);
	if($re){
		echo "<script>alert('保存完成');</script>";
	}
}


$sql = "select * from diyconfig limit 1";
$row = $GLOBALS['db']->getRow($sql);
$site_url = '';
$stage_s = 0;
$border_s = 0;
$jewelry_s = 0;
$calendar_s = 0;
if($row){
	$site_url = $row['site_url'];
	$stage_s = $row['stage_id'];
	$border_s = $row['border_id'];
	$jewelry_s = $row['jewelry_id'];
	$calendar_s = $row['calendar_id'];
}


$stage_list = cat_list(0, $stage_s, true);
$border_list = cat_list(0, $border_s, true);
$jewelry_list = cat_list(0, $jewelry_s, true);
$calendar_list = cat_list(0, $calendar_s, true);

$smarty->assign('site_url', $site_url);
$smarty->assign('stage_list',   $stage_list);
$smarty->assign('border_list',   $border_list);
$smarty->assign('jewelry_list',   $jewelry_list);
$smarty->assign('calendar_list',   $calendar_list);

/* 显示页面 */
assign_query_info();
$smarty->display('source_info.htm');
?>